#单词计数
#文件写入 文件读取练习

#创建新文件，写入内容
f = open("E:\word.txt",'w',encoding='UTF-8')
f.write("itheima itcast python\n")
f.write("itheima python itcast\n")
f.write("beijing shanghai itheima\n")
f.write("shenzhen guangzhou itheima\n")
f.write("wuhan hangzhou itheima\n")
f.write("zhengzhou bigdata itheima\n")
f.close()

#统计itheima单词出现的个数
f = open("E:\word.txt",'r',encoding='UTF-8')
ret =f.read().count("itheima")
print(f"文件中‘itheima’出现的个数：{ret}")

#关闭文件
f.close()




